﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Security;
using System.Text;
using System.Threading.Tasks;

namespace Inaction.Core
{
    [Serializable]
    public class UniqueException : Exception, ISavableException
    {
        #region 属性
        public string UniqueName { get; set; }
        public Type Type { get; set; }
        public Guid Id { get; set; }
        #endregion

        [SecuritySafeCritical]
        protected UniqueException(SerializationInfo info, StreamingContext context)
        {
            UniqueName = info.GetString("UniqueName");
            Type = (Type)info.GetValue("Type", typeof(Type));
            Id = (Guid)info.GetValue("Id",typeof(Guid));
        }

        public override void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            base.GetObjectData(info, context);
            info.AddValue("UniqueName", UniqueName);
            info.AddValue("Type", Type);
            info.AddValue("Id", Id);
        }
        public UniqueException(string uniqueName, Guid id, Type type)
        {
            this.UniqueName = uniqueName;
            this.Id = id;
            this.Type = type;
        }
    }
}
